![]() This is were Html is extremely Awesome to use, since it provides the ability to link from one document page to the next, just by clinking on the hyperlinks. It is possible to setup hyperlinks using both text or images. For the moment we shall only be concerned with hyperlinks applied to text. The exact same principles described here for text links also apply to images which are discussed later. To set up a link, we use an anchor element <A> with its relative attributes. Lets begin with setting up a link to another web document in the current directory. I will illustrate this by setting up a link to a document called Dpage.html in this current directory. This is simply done by using the HREF attribute as shown below. <u><A HREF="Dpage.Html"> Click Here to link to dpage.html </A></u> The filename of the document is inserted after the HREF attribute (Dpage.html) and the text which is to be hyper linked is inserted between the start and end element (Click Here to link to Dpage.html). On moving the pointer over the link, it should transform into a hand indicating a link. Clinking on the link should transport you over to the Dummy page from were there is a link back here. Click Here to link to Dpage.html
The above link should be in blue, since i have included the
link attribute in the
body tag element
telling the browser that the links should be in blue on this page.This will
NOT
override any preferences set by the browser and hence the link may not be blue.
Note you do not need to underline the links as I have above. But i find it useful when web pages
contains coloured text. Of course older browsers will not recognize the
<u> tag element. Therefore it will not underline the text. You can also open documents in Subdirectories off the current directory. Lets set up a link to the document Dpage1.html in the directory called SubDirec off this current directory. You enter the path of the file as you would in dos. ie. <u><A HREF="SubDirec/Dpage1.Html"> Click Here to link to dpage1.html </A></u> As before the link appears in blue (or browsers pref.) and is underlined. Clinking on the link, you will see that the address in the address bar will change to include the above path. Click on the link to see how to link back to this document in this parent directory. Click Here to link to Dpage1.html
The above links are known as
Relative links since they refer to files which are relative
to the current directory.
<u> <A HREF=" http://members.xoom.com/MannanAli/LearHtml/subdirec/Dpage1.html "> Absolute link to Dpage1.html </A> <A HREF=" http://www.shef.ac.uk/ "> The University Of Sheffield </A> </u> Absolute link to Dpage1.html The University Of Sheffield
So when setting links, it is necessary to use
Absolute links
when linking to other web documents. | ||
We now move on to another attribute known as the named anchor (
Name).
< A name="Top "> [6] Links/Anchors < /A > < A name="LinkToDpage "> Click Here to link to Dpage.html < /A > in the appropriate sections of the web page, giving them a name so that one can then set up links to these points from anywhere in the web page, or from some other web page totally. In these cases the names I have used to identify these anchors are, top for the first, and LinkToDpage for the second. There are no constraints on the names used to identify the anchors, but one should avoid using names that are similar to HTML tags and repeat names obviously. The text/image which you wish to link to is simply placed between the anchor elements. For example, for the first link the title of this section is used as the anchor to link to the top of this web page and the sentence Click Here to link to Dpage.html, for the second example. To set a link to these anchors, we virtually use same HTML code as before.
Click <u><A HREF="#Top "> Here </A></u> to be transported to the top. Or you can click <u><A HREF="#LinkToDpage "> Here </A></u> to be transported to the link to Dpage.html This should give the following
Click Here to be transported to the top. Or you can click Here to be transported to the link to Dpage.html To link to an anchor point in a different web page, we use the same HTML Source code, with a tiny extra bit. The anchor point in the other web page is set up as shown above. Note here the web page is in the same site/directory.
Click <u><A HREF="section1.html#rgbcolours "> Here </A></u> to be transported to the RGB colours in section 1. The filename of the web page is section1.html , and the name of the anchor point in this document we want to link to is rgbcolours. Note the hash # before the anchor name.
Click Here to be transported to the RGB colours in section 1.
NOTE
if the name anchor does not exist in the web page you are referring to, then by default you start at
the top of the web page.
Click <u><A HREF="mailto:Mannan.Ali@physics.org "> Here </A></u> to send me an email at Mannan.Ali@physics.org or click <u><A HREF="mailto:php95ma@sheffield.ac.uk "> Here </A></u> to send me an email at php95ma@sheffield.ac.uk The above code sets up to links which will activate the email program.
Click Here to send me an email at Mannan.Ali@physics.org or click Here to send me an email at php95ma@sheffield.ac.uk Finally some browsers support the Title attribute within the anchor <A>element, similar to the alt attribute described in the next section for images. Basically, when a user holds the mouse pointer over a link for a given amount of time, the text in the Title attribute is displayed in a popup tooltip fashion. This provides an additional way of providing further information relating to the link.
Positioning the mouse pointer over <u><A HREF="#Top" Title="Links back to the top" > THIS LINK</A></u> will bring up a small popup window. The above code sets up a link to the top of this page.
Positioning the mouse pointer over THIS LINK will bring up a small popup window. ![]() ![]() ![]() | ||